﻿<phone:PhoneApplicationPage
    x:Class="ShoppingList.Lists"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:ShoppingList"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
    d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
    shell:SystemTray.IsVisible="True"
    Loaded="PhoneApplicationPage_Loaded">
    <phone:PhoneApplicationPage.Resources>
        <local:MainViewModel x:Key="MainViewModelDataSource" d:IsDataSource="True"/>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ListName" Text="{StaticResource AppTitle}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <ListBox DataContext="{Binding}" ItemsSource="{Binding Path=Lists}" Name="ListsList"
                     ItemContainerStyle="{StaticResource ListBoxItemStyle1}" SelectedItem="{Binding Path=CurrentList, Mode=TwoWay}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="0,0,0,5" MinWidth="465"  >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition MinWidth="365"/>
                                <ColumnDefinition Width="52"/>
                            </Grid.ColumnDefinitions>
                            <StackPanel Margin="0,0,0,0" Grid.Column="0" VerticalAlignment="Center">
                                <TextBlock Text="{Binding Path=Name}" Visibility="Visible"
                                               TextWrapping="Wrap" />
                                <TextBlock Text="{Binding Path=Date}" x:Name="Date" TextWrapping="Wrap"
                                           Style="{StaticResource PhoneTextSmallStyle}"
                                           Visibility="{Binding Path=Selected,
                                    Converter={StaticResource BooleanToVisibilityConverter}}" />
                                <StackPanel Orientation="Horizontal"
                                            Visibility="{Binding Path=Selected,
                                    Converter={StaticResource BooleanToVisibilityConverter}}" >
                                    <TextBlock Text="List sum:" Style="{StaticResource PhoneTextSubtleStyle}"></TextBlock>
                                    <TextBlock DataContext="{Binding}" Text="{Binding Path=ListSum}" Style="{StaticResource PhoneTextSubtleStyle}"></TextBlock>
                                    <TextBlock Text="Cart sum:" Style="{StaticResource PhoneTextSubtleStyle}"></TextBlock>
                                    <TextBlock DataContext="{Binding}" Text="{Binding Path=CartSum}" Style="{StaticResource PhoneTextSubtleStyle}"></TextBlock>
                                </StackPanel>
                            </StackPanel>
                            <Button x:Name="AddItem" Width="60" Height="60"
                                        Padding="0,-8,0,0"  Margin="0,0,0,0" Visibility="Visible"
                                        BorderThickness="0"   HorizontalAlignment="Right"
                                        Click="SelectItem_Click" Grid.Column="1" VerticalAlignment="Center">
                                <Path x:Name="Check_1034" Width="25" Height="21"
                                          Canvas.Left="770" Canvas.Top="388.332" Stretch="Fill" Data="F1 M 785,390.453L 782.878,388.332L 775.196,396.012L 772.122,392.937L 770,395.058L 775.192,400.251L 785,390.453 Z "
                                          Stroke="{StaticResource PhoneForegroundBrush}" Fill="{StaticResource PhoneBackgroundBrush}" StrokeThickness="2" DataContext="{Binding}"/>
                            </Button>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

        </Grid>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="Load sample data" Click="ApplicationBarMenuItemLoadSampleData_Click" />
                <!--<shell:ApplicationBarMenuItem Text="MenuItem 2"/>-->
            </shell:ApplicationBar.MenuItems>
            <shell:ApplicationBarIconButton IconUri="/Images/white/add.png" Text="Add list" Click="ApplicationBarAddItemButton_Click" />
            <shell:ApplicationBarIconButton IconUri="/Images/white/edit.png" Text="Edit name" Click="ApplicationBarEditItemButton_Click" />
            <shell:ApplicationBarIconButton IconUri="/Images/white/delete.png" Text="Delete list" Click="ApplicationBarDeleteButton_Click" IsEnabled="False"/>
            <shell:ApplicationBarIconButton IconUri="/Images/white/mail.png" Text="Email list" Click="ApplicationBarEmailButton_Click" />
            <!--<shell:ApplicationBarIconButton IconUri="/Images/white/save.png" Text="Save list" Click="ApplicationBarSaveButton_Click" />-->
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>